package org.soc.timesheet.server.domain.service;

import java.util.List;

import org.soc.timesheet.custom.domain.filters.CustomersEnabledFilter;
import org.soc.timesheet.custom.domain.filters.RolesFilter;
import org.soc.timesheet.domain.CustomersEnabled;
import org.soc.timesheet.domain.Roles;
import org.soc.timesheet.domain.repository.CustomersEnabledRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CustomersEnabledServiceImpl implements CustomersEnabledService {

	@Autowired
    CustomersEnabledRepository customersEnabledRepository;

	public long countAllCustomersEnableds() {
        return customersEnabledRepository.count();
    }

	public void deleteCustomersEnabled(CustomersEnabled customersEnabled) {
        customersEnabledRepository.delete(customersEnabled);
    }

	public CustomersEnabled findCustomersEnabled(Integer id) {
        return customersEnabledRepository.findOne(id);
    }

	public List<CustomersEnabled> findAllCustomersEnableds() {
        return customersEnabledRepository.findAll();
    }

	public List<CustomersEnabled> findCustomersEnabledEntries(int firstResult, int maxResults) {
        return customersEnabledRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveCustomersEnabled(CustomersEnabled customersEnabled) {
        customersEnabledRepository.save(customersEnabled);
    }

	public CustomersEnabled updateCustomersEnabled(CustomersEnabled customersEnabled) {
        return customersEnabledRepository.save(customersEnabled);
    }

	@Override
	public Page<CustomersEnabled> findAll(PageRequest pageRequest) {
		// TODO Auto-generated method stub
		return customersEnabledRepository.findAll(pageRequest);
	}

	@Override
	public Page<CustomersEnabled> findByFilters(CustomersEnabledFilter filter, PageRequest pageRequest) {
		// TODO Auto-generated method stub
		return customersEnabledRepository.findAll(filter, pageRequest);
	}
}
